package com.cskaoyan.service.impl;

import com.cskaoyan.mapper.MarketIssueMapper;
import com.cskaoyan.model.MarketIssue;
import com.cskaoyan.model.MarketIssueExample;
import com.cskaoyan.service.IssueService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Pudding
 * @Date 2024/6/12 23:01
 */
@Service
public class IssueServiceImpl implements IssueService {
    @Autowired
    MarketIssueMapper issueMapper;

    @Override
    public List<MarketIssue> findAll() {
        //1. 构造查询条件
        MarketIssueExample example = new MarketIssueExample();
        example.createCriteria().andDeletedEqualTo(false);
        example.setOrderByClause("add_time desc");

        //2. 进行查询
        List<MarketIssue> issues = issueMapper.selectByExample(example);
        return issues;
    }

    @Override
    public List<MarketIssue> list(Integer page, Integer limit) {
        //1. 构造查询条件
        MarketIssueExample example = new MarketIssueExample();
        example.createCriteria().andDeletedEqualTo(false);
        example.setOrderByClause("add_time desc");
        PageHelper.startPage(page, limit);

        //2. 进行查询
        List<MarketIssue> issues = issueMapper.selectByExample(example);
        return issues;
    }
}
